<?php include("src/addEmployed_cs.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href='css/coolMessage.css' type='text/css' rel='stylesheet' media='screen' />
<title>Adicionar Empleado :: ASSC</title>
<script language="javaScript" type="text/javascript" src="js/jquery.js"></script>
<script language="javaScript" type="text/javascript" src="js/jquery.simplemodal.js"></script>
<script language="javaScript" type="text/javascript" src="js/coolMessage.js"></script>

<link rel="stylesheet" type="text/css" media="all" href="includes/calendario/calendar-system.css" title="system" />
<script type="text/javascript" src="includes/calendario/calendar.js"></script>
<script type="text/javascript" src="includes/calendario/lang/calendar-es.js"></script>
<script type="text/javascript" src="includes/calendario/calendar-setup.js"></script>

<script language="javascript" type="text/javascript">
	
	var displayRow = '';
	if (navigator.appName == "Netscape")
		displayRow = 'table-row';
	else if (navigator.appName.indexOf("Explorer") != -1) 
		displayRow = 'block';
	
	var cont = 1;
	var maximum = 5
	function most(){
		document.getElementById("tr_phones").style.display = displayRow;
		if (cont < maximum ){
			cont++;
			$("#div_campo").append("<div id='div_tel_number_"+cont+"'>"+cont+". <input type='text' id='tel_number_"+cont+"' name='tel_number[]' class='text_grv' size='15' maxlength='14'/> <input type='text' id='tel_ext_"+cont+"' name='tel_ext[]' class='text_grv' size='3' maxlength='5'/></div>");
		}
		if(cont >0)
			document.getElementById('btnLess').disabled = 0;
	}
	
	function less(){
		if( cont == 2 )
			document.getElementById("tr_phones").style.display = 'none';
		
		if(cont > 1 ){
			$("#div_tel_number_"+cont).remove();
			cont--;
		}   
		if(cont == 1)
			document.getElementById('btnLess').disabled = 1;
	}
	
	function isMail(valor) {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
			return (true);
		else
			return (false);
	}

	function validate(action){
		document.getElementById("action").value = action;//1: save, 2: save and continue.
		
		var msg = '';
		var name   			= document.getElementById("hdv_name").value;
		var lastname		= document.getElementById("hdv_lastname").value;
		var cedula   		= document.getElementById("hdv_cedula").value;
		var address   		= document.getElementById("hdv_address").value;
		var city     		= document.getElementById("hdv_city").value;
		var state_code 		= document.getElementById("state_code").value;
		
		if(name == '') 
			msg='- Por favor entre el nombre del Empleado. <br />';
			
		if(lastname == '') 
			msg='- Por favor entre el apellido del Empleado. <br />';	
		
		if(cedula == '') 
			msg='- Por favor entre la cedula del Empleado. <br />';
			
		if(address == '') 
			msg='- Por favor entre la direccion del Empleado. <br />';
			
		if(city == '') 
			msg= msg+'- Por favor entre la ciudad. <br />';
			
		if(state_code == '') 
			msg= msg+'- Por favor entre el Departamento. <br />';	
		
	
//		if(cli_email == '') 
//			msg='- Please enter the email. <br />';
//		else{
//			if ( ! isMail (cli_email) )
//				msg += '- Wrong email.<br />';
//		}
		
		var a = 1
		while(a <= cont){
			var c = document.getElementById("tel_number_"+a).value
			if(c == '')
				msg += '- Por favor entre el telefono '+a+'. <br />';
			a++;
		}
		

		if(msg==''){
			document.getElementById('form').submit();
			return true;
		}
		else{
			coolMessage("alert", msg);
			return false;
		}		
	}
	

	function onlyNumbers(e)
	{
	   var key;
	   if(window.event)
		  key = window.event.keyCode;   //IE
	   else
		  key = e.which;                //firefox
	   if (!( (key >= 48 && key <= 57) || key ==8 || key ==9 || key ==0 || key ==46 ))
		  return false;
	   else
		  return true;
	}	
	
</script>
</head>
<body>
<?php $item_select = 9;include("menu.php");?><br />
    <form name="form" id="form" method="post" action="" enctype="multipart/form-data">
    <input type="hidden" name="addEmployed" id="addEmployed" value="1"/>
	<input type="hidden" name="action" id="action" value="1"/>
    
    <div class="content_grv">
		<table width="80%" align="center" class="shadow">
            <tr>
                <td class="title">Informacion Empleado</td>
            </tr>
            <tr>
                <td>
                    <table class="tbl_form" align="center">
                        <tr>
                            <td width="35%" align="right"><span class="lbl_gray">Nombre:</span></td>
                            <td width="1%">&nbsp;</td>
                            <td><input type="text" name="hdv_name" id="hdv_name" class="text_grv" size="31" maxlength="30" /></td>
                        </tr>
                        <tr>
                            <td width="35%" align="right"><span class="lbl_gray">Apellido:</span></td>
                            <td width="1%">&nbsp;</td>
                            <td><input type="text" name="hdv_lastname" id="hdv_lastname" class="text_grv" size="31" maxlength="30" /></td>
                        </tr>
                        <tr>
                            <td width="35%" align="right"><span class="lbl_gray">Cedula:</span></td>
                            <td width="1%">&nbsp;</td>
                            <td><input type="text" name="hdv_cedula" id="hdv_cedula" class="text_grv" size="21" maxlength="20" /></td>
                        </tr>
                        <tr>
                        	<td align="right"><span class="lbl_gray">Celular:</span><br /><span class="lbl_gray_small">Telefono :</span></td>
                            <td>&nbsp;</td>
                            <td>                                    
                                1. <input type="text" name="tel_number[]" id="tel_number_1" class="text_grv" size="15" maxlength="14" />
                                <input type="text" name="tel_ext[]" id="tel_ext_1" class="text_grv" size="3" maxlength="5" />
                                <input type="button" value="+" onClick="javascript: most();" class="button_grv"/>&nbsp;
                                <input type="button" value="-" id="btnLess" onClick="javascript: less()" class="button_grv_cancel" disabled="disabled"/>
                            </td>
                        </tr>
                        <tr id="tr_phones" style="display:none">
                        	<td align="right" valign="top"><span class="lbl_gray">Mas Telefonos:</span></td>
                            <td>&nbsp;</td>
                            <td>
                            	<div id="div_campo">
                                
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td align="right"><span class="lbl_gray">Address:</span></td>
                            <td>&nbsp;</td>
                            <td><input type="text" name="hdv_address" id="hdv_address" class="text_grv" size="41" maxlength="40"/></td>
                        </tr>
                        <tr>
                            <td align="right"><span class="lbl_gray">Ciudad:</span></td>
                            <td>&nbsp;</td>
                            <td><input type="text" name="hdv_city" id="hdv_city" class="text_grv" size="21"  maxlength="20" /></td>
                        </tr>
                        <tr>
                            <td align="right"><span class="lbl_gray">Departamento:</span></td>
                            <td>&nbsp;</td>
                            <td><select name="state_code" id="state_code" class="text_grv">
                                <option value="" selected="selected" disabled="disabled">Seleccione..</option>
                                <?php for($i=0; $i<count($states);$i++) {?>
                                <option value="<?php echo $states[$i]->state_code;?>"><?php echo $states[$i]->state_name;?></option>
                                <?php }?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td align="right"><span class="lbl_gray">Fecha Nacimiento:</span></td>
                            <td>&nbsp;</td>
                            <td><input name="hdv_birth" type="text" style="width:100px" readonly="readonly" id="hdv_birth" maxlength="45" class="text_grv"
				value="<?php if(isset($hdv_birth)) echo $hdv_birth?>"/>
			    <input name="imagea" type="image" id="calendar1" src="images/mostrar_calendario.png" align="absmiddle" width="18" height="16"/></td>
				<script type="text/javascript">
						Calendar.setup({
						inputField : "hdv_birth",							
						ifFormat : "%Y/%d/%m",
						showsTime : false,
						button : "calendar1", 
						step : 1
						});
				</script>
                        </tr>
                       
                        <tr>
                            <td align="right"><span class="lbl_gray">Email:</span></td>
                            <td>&nbsp;</td>
                            <td><input type="text" name="hdv_email" id="hdv_email" class="text_grv" size="51"  maxlength="50" /></td>
                        </tr>
                        <tr>
                            <td colspan="3" align="center">&nbsp;</td>
                        </tr>
                        <tr>
                            <td colspan="3" align="center">
                                <input type="button" class="button_grv" value="Save" onclick="javascript: return validate(1);" />
                                <input type="button" class="button_grv" value="Save and continue" onclick="javascript: return validate(2);" />
                                <input type="reset" value="Reset" class="button_grv_cancel"/>
                                <input type="button" class="button_grv_cancel" value="Cancel" onClick="javascript:window.location.href='listEmployed.php';" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
 	</div>
</form>    
</body>
</html>
<?php include('divscoolmessage.php');?>